Skip to content

chore: code audit improvements and ci infrastructure - #24

Merged
kacy merged 1 commit into
mainfrom
chore/code-audit-fixes
Feb 6, 2026
Merged

chore: code audit improvements and ci infrastructure#24
kacy merged 1 commit into
mainfrom
chore/code-audit-fixes

Conversation

@kacy

@kacy kacy commented Feb 6, 2026

Copy link
Copy Markdown
Owner

Summary

Comprehensive code audit addressing infrastructure gaps and code quality improvements.

Infrastructure additions

  • rust-toolchain.toml: pins Rust 1.93 with fmt/clippy components for reproducible builds
  • .cargo/config.toml: release optimizations (LTO, strip symbols, single codegen unit)
  • .github/workflows/ci.yml: automated CI with format checks, clippy, tests (ubuntu + macos), and security audits via cargo-audit
  • CONTRIBUTING.md: development workflow and code standards for contributors

Code improvements

  • glob_match(): rewrote with O(n*m) iterative two-pointer algorithm instead of O(n²) recursive backtracking — prevents potential DOS on patterns like *a*b*c*d
  • SCAN cursor validation: added guard against invalid cursor values (shard_id out of range)
  • documentation: improved docs for memory overhead constants, LRU sampling approximation, and SCAN cursor encoding format

Test plan

  • all 410 tests pass
  • cargo fmt --check passes
  • cargo clippy -- -D warnings passes
  • glob pattern tests verify new algorithm handles all cases

Design considerations

The glob_match rewrite uses an iterative backtracking approach that:

  1. Records the position of each * encountered
  2. On mismatch, backtracks to the last * and tries consuming one more char
  3. Linear in the number of stars, avoiding exponential blowup

This is the same algorithm used by Redis and most shell glob implementations.

infrastructure:
- add rust-toolchain.toml to pin rust 1.93 with fmt/clippy components
- add .cargo/config.toml with release optimizations (lto, strip, codegen-units)
- add .github/workflows/ci.yml for automated testing, linting, and security audits
- add CONTRIBUTING.md with development workflow and code standards

code improvements:
- rewrite glob_match() with O(n*m) iterative algorithm instead of O(n²) recursive
- add cursor validation in SCAN handler to guard against invalid shard_id
- improve documentation for memory overhead constants and LRU sampling
- document SCAN cursor encoding format (shard_id << 48 | position)
- fix clippy lint (use is_multiple_of instead of % 2 != 0)
@kacy
kacy merged commit 373c87c into main Feb 6, 2026
5 checks passed
kacy added a commit that referenced this pull request Feb 11, 2026
chore: code audit improvements and ci infrastructure
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant